package com.bawei.module_live

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import com.alibaba.android.arouter.facade.annotation.Route
import com.bawei.library_common.BaseApplication
import com.bawei.library_common.ConstanstValue
import com.bawei.library_common.route.ARouterFragmentPath
import com.bawei.library_common.utils.UserUtils
import kotlin.random.Random

@Route(path = ARouterFragmentPath.PAGER_LIVE)
class LiveFragment : Fragment() {

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?,
    ): View? {
        val view = inflater.inflate(R.layout.live_fragment_live, container, false)
        //开始直播
        view.findViewById<Button>(R.id.bt).setOnClickListener {
            val roomName = UserUtils.getCurrentUser()?.username+ Random(1000).nextInt()
            BaseApplication.socketUtils.sendMsg(ConstanstValue.LIVE_FLAG+ConstanstValue.SPLITFLAG+UserUtils.getCurrentUserJson()+ConstanstValue.SPLITFLAG+roomName)
        }
        return view
    }
}